112A - Petya and Strings - CodeForces Solution


implementation strings *800

Please click on ads to support us..

Python Code:

a=input("").lower()
b=input("").lower()
f=0
for i in range(len(a)):
    if ord(a[i])>ord(b[i]):
        f=1
        break
    elif ord(a[i])<ord(b[i]):
        f=-1
        break
    else:
        f=0
print(f)

C++ Code:

#include <iostream>
#include<string>
#include<cctype>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string str;
    cin >> str;
   for(int i = 0;i<s.size();i++){
       s[i] = tolower(s[i]);
       str[i] = tolower(str[i]);
   }
   if(str == s){
       cout << 0<<  endl;
   }
   else{
       
   
   for(int i = 0 ;i<s.size();i++){
       if(s[i]<str[i]){
           cout  << -1 <<endl;
           break;
           
       }
       else if(s[i]>str[i]){
           cout << 1 << endl;
           break;
       }
   }
   }

    return 0;
}


Comments

Submit
0 Comments
More Questions

1418C - Mortal Kombat Tower
1382B - Sequential Nim
1272C - Yet Another Broken Keyboard
808A - Lucky Year
1245A - Good ol' Numbers Coloring
58B - Coins
1041C - Coffee Break
507A - Amr and Music
1041D - Glider
1486A - Shifting Stacks
1389B - Array Walk
71B - Progress Bar
701A - Cards
545A - Toy Cars
1538E - Funny Substrings
234A - Lefthanders and Righthanders
1611D - Weights Assignment For Tree Edges
197A - Plate Game
1474A - Puzzle From the Future
6B - President's Office
1405B - Array Cancellation
431C - k-Tree
101A - Homework
1642C - Great Sequence
1523B - Lord of the Values
1406C - Link Cut Centroids
2409. Count Days Spent Together
2410. Maximum Matching of Players With Trainers
1604C - Di-visible Confusion
997A - Convert to Ones